//
//  TableViewCell.m
//  TableViewCell边距缩进
//
//  Created by jyh on 2018/5/16.
//  Copyright © 2018年 huig. All rights reserved.
//

#import "TableViewCell.h"
#import "Model.h"

@interface TableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *lab;
@end
@implementation TableViewCell

+ (instancetype)tableViewCell:(UITableView *)tableView {
    

    static NSString *cellID = @"cellID";
    
    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        
        cell = [[[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:nil options:nil] firstObject];
    }
    
    cell.backgroundColor = [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:0.15];
    
    return cell;
}

- (void)setModel:(Model *)model {
    
    _model = model;
    
    self.lab.text = model.name;
}



- (void)setFrame:(CGRect)frame{
    
    NSLog(@"self.frame = %@  frame = %@",NSStringFromCGRect(self.frame),NSStringFromCGRect(frame));
    
    if (frame.origin.x == 0) {
        frame.origin.x = 10;
    }
    
    if (frame.origin.x > 10) {
        frame.origin.x = frame.origin.x + 10;
    }

    if (frame.size.height == 100) {
        frame.size.width -= 2 * 10;
        frame.origin.y += 10;
        frame.size.height -= 10;
    }

    [super setFrame:frame];
}


- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
